home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15194 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.infinet.com!cedwards
  2. From: cedwards@infinet.com (Chad Edwards)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How do you reset a file?
  5. Date: 4 Apr 1996 04:15:06 GMT
  6. Organization: InfiNet
  7. Message-ID: <4jvica$86n@news1.infinet.com>
  8. References: <3162b143.399039@news.airmail.net> <4jv1vc$ha1@news.nynexst.com>
  9. NNTP-Posting-Host: user.infinet.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Ramesh Nagabushnam (rcn@east) wrote:
  13. : Elizabeth Cunningham (liz@iadfw.net) wrote:
  14. : : This might be a stupid question, but I couldn't find the answer in
  15. : : either of the C++ books I have.  How do you reset an fstream object
  16. : : back to the beginning of the file? 
  17.  
  18. : Your question could be interpreted >= 2 ways
  19.  
  20. : 1) You just want to move the file pointer:
  21. :  
  22. :    fstream fobj(..);
  23.  
  24. :    fobj.seekpos(0,mode);  // see man filebuf
  25.  
  26. : 2) You wish to truncate the file:
  27.  
  28. :    fstream fobj(..);
  29.  
  30. :    ftruncate(fobj.fd(),0);  // see man ftruncate(), man filebuf
  31.  
  32. : -r
  33. : ____________________________________________________
  34. :   Ramesh Nagabushnam,           (o) (914) 644-2711 
  35. :   rcn@nynexst.com               (h) (203) 967-1129
  36.  
  37. --
  38.  
  39.  
  40. what about the rewind function?
  41.  
  42.  
  43. ______________________________________________________________________________
  44. A SIG? What the heck is a Sig? Something you smoke?
  45. http://www.infinet.com/~cedwards 
  46.  
  47. Home of:
  48.  
  49.   ****   ****      *     *
  50.  *      *    *   *   *   * 
  51.  *      *    *   * * *   * 
  52.   ****   ****   *     *  *****
  53. Columbus Ohio APBA League
  54. _______________________________________________________________________________
  55.  
  56.